﻿
using PsqlDotnet.Enums;
namespace PsqlDotnet
{
    public class PsqlBanners
    {
        public const string CreateUserBanner = "CREATE ROLE";
        public const string RemoveUserBanner = "DROP ROLE";
        public const string AlterUserBanner = "ALTER ROLE";
        public const string CreateGroupBanner = "CREATE ROLE";
        public const string RemoveGroupBanner = "DROP ROLE";
        public const string AddUserToGroupBanner = "ALTER ROLE";
        public const string RemoveUserFromGroupBanner = "ALTER ROLE";
        public const string CreateDatabaseBanner = "CREATE DATABASE";
        public const string RemoveDatabaseBanner = "DROP DATABASE";
        public const string CreateTableBanner = "CREATE TABLE";
        public const string ErrorBanner = "ERROR";

        public bool CompareBanners(string bannerStr, PsqlBannersEnum bannerType)
        {
            bool result = false;

            switch (bannerType)
            {
                case PsqlBannersEnum.CreateUser:
                    result = bannerStr.Trim().ToUpper() == CreateUserBanner;
                    break;
                case PsqlBannersEnum.RemoveUser:
                    result = bannerStr.Trim().ToUpper() == RemoveUserBanner;
                    break;
                case PsqlBannersEnum.AlterUser:
                    result = bannerStr.Trim().ToUpper() == AlterUserBanner;
                    break;
                case PsqlBannersEnum.CreateGroup:
                    result = bannerStr.Trim().ToUpper() == CreateGroupBanner;
                    break;
                case PsqlBannersEnum.RemoveGroup:
                    result = bannerStr.Trim().ToUpper() == RemoveGroupBanner;
                    break;
                case PsqlBannersEnum.AddUserToGroup:
                    result = bannerStr.Trim().ToUpper() == AddUserToGroupBanner;
                    break;
                case PsqlBannersEnum.RemoveUserFromGroup:
                    result = bannerStr.Trim().ToUpper() == RemoveUserFromGroupBanner;
                    break;
                case PsqlBannersEnum.CreateDatabase:
                    result = bannerStr.Trim().ToUpper() == CreateDatabaseBanner;
                    break;
                case PsqlBannersEnum.RemoveDatabase:
                    result = bannerStr.Trim().ToUpper() == RemoveDatabaseBanner;
                    break;
                case PsqlBannersEnum.CreateTable:
                    result = bannerStr.Trim().ToUpper() == CreateTableBanner;
                    break;
            }

            return result;
        }
    }
}
